package yunhe.servlet;

import org.json.JSONArray;
import org.json.JSONObject;
import yunhe.biz.EmpMsgBiz;
import yunhe.biz.impl.EmpMsgBizImpl;
import yunhe.entity.EmpMsg;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by lzh on 2017/6/16.
 */
@WebServlet(name = "GetAllEmpServlet",urlPatterns = "/stockmgr/GetAllEmpServlet")
public class GetAllEmpServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        EmpMsgBiz emb=new EmpMsgBizImpl();
        List<EmpMsg> lem=emb.getAllEmp();
        JSONArray ja=new JSONArray();
        for(EmpMsg em:lem){
            JSONObject jb=new JSONObject(em);
            ja.put(jb);
        }
        response.getWriter().print(ja.toString());
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
